<template>
  <div>
    <MyCard btn-text="添加" @btn-fn="router.push('/pms/addProductCate')" />
    <el-table :data="userList" border style="width: 100%">
      <el-table-column prop="id" label="编号" />
      <el-table-column prop="name" label="分类名称" width="528" />
      <el-table-column prop="address" label="级别">
        <template #default="{ row }">
          {{ row.level == 0 ? "一级" : "二级" }}
        </template>
      </el-table-column>
      <el-table-column prop="productCount" label="商品数量" />
      <el-table-column prop="productUnit" label="数量单位" />
      <el-table-column prop="navStatus" label="导航栏">
        <template #default="{ row }">
          <el-switch
            v-model="row.navStatus"
            :active-value="1"
            :inactive-value="0"
          />
        </template>
      </el-table-column>
      <el-table-column prop="showStatus" label="是否显示">
        <template #default="{ row }">
          <el-switch
            v-model="row.showStatus"
            :active-value="1"
            :inactive-value="0"
          />
        </template>
      </el-table-column>
      <el-table-column prop="level" label="排序" />
      <el-table-column prop="address" label="设置" width="200">
        <template #default="{ row }">
          <el-button style="width: 80px">查看下级</el-button>
          <el-button style="width: 80px">移除商品</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="address" label="操作" width="200">
        <template #default="{ row }">
          <el-button>编辑</el-button>
          <el-button type="danger">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页器 -->
    <el-pagination
      v-model:current-page="paginationParams.currentPage4"
      v-model:page-size="paginationParams.pageSize4"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper"
      :background="true"
      :total="paginationParams.total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup lang="ts">
import MyCard from "@/components/MyCard/index.vue";
import { useTableFn } from "@/hooks/component/useTable";
import { ref } from "vue";
import { useRouter } from "vue-router";
import * as http from "./api/http";
const value1 = ref(true);
const tableData = [
  {
    date: "2016-05-03",
    name: "Tom",
    address: "No. 189",
  },
  {
    date: "2016-05-02",
    name: "Tom",
    address: "No. 189",
  },
  {
    date: "2016-05-04",
    name: "Tom",
    address: "No. 189",
  },
  {
    date: "2016-05-01",
    name: "Tom",
    address: "No. 189",
  },
];
let {
  userList,
  paginationParams,
  handleSizeChange,
  handleCurrentChange,
  queryList,
} = useTableFn(http.productCate.ProductCategoryList, {}, 0);
const router=useRouter();
</script>

<style lang="less" scoped>
:deep(.el-pagination) {
  float: right;
}
</style>
